import axios from 'axios'
import {
    Message,
    MessageBox
} from 'element-ui'
import store from '../store'

// 创建axios实例
const service = axios.create({
    baseURL: 'http://175.178.3.253:88', // api 的 base_url
    timeout: 100000, // 请求超时时间,
})

// 请求计数器

// request拦截器
service.interceptors.request.use(config => {

    return config
}, error => {
    // Do something with request error
    console.log(error) // for debug
})

service.interceptors.response.use(
    response => {
        /**
         * code为非200是抛错 可结合自己业务进行修改
         */

        return response
    },
    error => {
        console.log('err' + error) // for debug
        Message({
            message: error.msg,
            type: 'error',
            duration: 3 * 1000
        })
        return Promise.reject(error)
    }
)

export default service